1. Field of the Invention
Apparatuses and methods consistent with the present invention relate to using a nonvolatile memory as a cache in a storage apparatus and recovering mapping information, and more particularly, to a storage apparatus which uses a nonvolatile memory as a cache, and is capable of safely recovering mapping information, and a mapping information recovering method for the storage apparatus.
2. Description of the Related Art
Generally, nonvolatile memories are widely used in embedded systems, such as electric home appliances, communication devices and set-top boxes, as storage media for storing and processing data.
Flash memories, which are one of the most widely used nonvolatile memories, are nonvolatile memory devices that can electrically erase or rewrite data. Flash memories consume less power than storage media based on magnetic disk memories and have access time as fast as hard disks. In addition, since flash memories are small, they are suitable for handheld devices.
Nonvolatile memories have recently been used as caches of storage media such as hard disk drives, thereby reducing power consumption of the hard disk drives and the time taken to boot systems using the nonvolatile memories as the caches. If a nonvolatile memory is used as a cache, when a host desires to store data in a hard disk drive, the data is first stored in the nonvolatile memory. Then, when there is no more storage space left in the nonvolatile memory, the data stored in the nonvolatile memory is moved to the hard disk drive. Since the power supply to the hard disk drive can be cut off while the data is read or written from/to the nonvolatile memory, power consumption can be reduced.
Storage apparatuses using nonvolatile memories as caches require mapping information for converting logical block addresses into physical block addresses so that hosts can access the physical block addresses of nonvolatile memories through the logical block addresses.
Mapping information is generally stored in volatile memories when hard disk drives are operated, and stored in nonvolatile memories when the hard disk drives are tuned off. Then, when the hard disk drives are turned on again, the mapping information stored in the nonvolatile memories is reloaded into the volatile memories so that hosts can access data based on the mapping information.
Characteristically, storage apparatuses using nonvolatile memories as caches may unexpectedly be turned off. In this case, since mapping information stored in volatile memories cannot be stored in the nonvolatile memories, a process of recovering the mapping information is required.
Related art methods of recovering mapping information include a method of scanning an entire nonvolatile memory and a method of periodically storing mapping information in a nonvolatile memory.
According the method of scanning an entire nonvolatile memory, the entire nonvolatile memory is scanned to find detection data stored in a next physical block address of a last allocated physical block address as illustrated in FIG. 1. Here, data is classified into effective data and ineffective data, and mapping information is recovered as illustrated in FIG. 2.
In this method, the entire nonvolatile memory may be scanned twice in the worst case, that is, once for finding the detection data and once for recovering mapping information. In this case, since the time required to scan the nonvolatile memory is increased, it takes a longer time to boot a system that uses the nonvolatile memory.
According to the method of periodically storing mapping information in a nonvolatile memory, the mapping information is periodically stored in the nonvolatile memory to avoid scanning the entire nonvolatile memory as described above.
Therefore, when a storage apparatus using the nonvolatile memory as a cache is booted next time, a host can access data stored in the nonvolatile memory based on the mapping information that is stored in the nonvolatile memory.
However, in this method, the mapping information is too frequently and unnecessarily stored in the nonvolatile memory. In other words, the mapping information is stored in the nonvolatile memory not only when the storage apparatus using the nonvolatile memory as a cache is turned off, but also when the storage apparatus is operated, which becomes a major cause of performance deterioration of the storage apparatus.
Korean Laid-Open Patent Publication No. 1998-0063018 discloses a cache memory device which can reduce initial line fetch time by allowing a user to deliberately fill the cache memory device with data when a computer is booted or reset. Generally, it requires a lot of time to bring data from a cache memory device to a main memory device through a line fetch operation when a computer is booted or reset. Furthermore, since a start address for the line fetch operation is determined arbitrarily, the line fetch operation may have to be performed several times in the worst case. The above related art is designed to solve these problems. However, it fails to suggest a method of rapidly recovering mapping information in the event of an unexpected power failure and minimizing storage space required for recovering the mapping information.